#include "HThermVector3.h"

#include "Constants.h"
#include "Parameters.h"

#include <cmath>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_rng.h>
#include <iostream>
#include <ctime>

HThermVector3::HThermVector3(Layer mag)
{
  Parameters *p=Parameters::getInstance();
  if(p->getDouble("temperature")==0)
    {
      x=0;
      y=0;
      z=0;
    }
  else
    {
      double variance=2*Constants::KB*p->getDouble("temperature")*mag.getAlpha()/(Constants::MU0*Constants::GAMMA*mag.getMs()*mag.getThickness()*mag.getSurface()*p->getDouble("timeStep"));
      variance=sqrt(variance);
      gsl_rng * r=gsl_rng_alloc(gsl_rng_taus);
      gsl_rng_set(r,time(NULL));
      x=gsl_ran_gaussian(r,variance);
      y=gsl_ran_gaussian(r,variance);
      z=gsl_ran_gaussian(r,variance);
      gsl_rng_free(r);
    }
}

HThermVector3::~HThermVector3()
{

}
